UserFeedsPortlet = Class.extend({
	init: function()	{
		this.name = "UserFeedsPortlet";
	},
	
	onBegin: function()	{
		this.page = 0;
		this.registerObserver();
	},
	
	onReloadPage: function()	{
		this.run();
	},
	
	run: function()	{
		var obj = this;
		var id = this.getRequest().getParam('id');
		this.onAjax('feed', 'load-feeds', {page: this.page, id: id}, 'GET', {
			'onSuccess': function(ret)	{
				obj.model = {};
				obj.model.feeds = ret;
				obj.getPortletPlaceholder().paintCanvas(obj.render());
			}
		});
	},
	
	onFeedsChanged: function()	{
		this.run();
	},
	
	onViewMoreFeeds: function()	{
		this.page++;
		var obj = this;
		var id = this.getRequest().getParam('id');
		this.onAjax('feed', 'load-feeds', {page: this.page, id: id}, 'GET', {
			'onSuccess': function(ret)	{
				obj.model = {};
				obj.model.feeds = ret;
				if (ret.length == 0)	{
					alert('Không còn post để hiển thị');
				}
				obj.requestForEffectiveResource('MoreFeeds').append(obj.renderView('MoreFeedsTmpl', obj.model));
			}
		});
	},
	
	onEnd: function()	{
		this.unregisterObserver();
	}
}).implement(PortletInterface).implement(RenderInterface).implement(AjaxInterface).implement(ObserverInterface);